package com.xncoding.wechat.dto;

import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class BankCardElement {
    /**
     * 证件类型
     * 1:身份证 2:护照 5:回乡证 9:台胞证 17:港澳居民居住证 18:台湾居民居住证
     */
    private Integer creType;

    @NotBlank(message = "证件号码不能为空")
    private String creId;

    @NotBlank(message = "真实姓名不能为空")
    private String trueName;
    public BankCardElement() {}

    public BankCardElement(Integer creType, String creId, String trueName) {
        this.creType = creType;
        this.creId = creId;
        this.trueName = trueName;
    }

    // 证件类型常量
    public static class CreType {
        public static final int ID_CARD = 1;          // 身份证
        public static final int PASSPORT = 2;         // 护照
        public static final int HOMECOMING_PERMIT = 5; // 回乡证
        public static final int COMPATRIOT_CARD = 9;   // 台胞证
        public static final int HK_RESIDENT_PERMIT = 17; // 港澳居民居住证
        public static final int TW_RESIDENT_PERMIT = 18; // 台湾居民居住证
    }

    // Getter and Setter
    public Integer getCreType() { return creType; }
    public void setCreType(Integer creType) { this.creType = creType; }

    public String getCreId() { return creId; }
    public void setCreId(String creId) { this.creId = creId; }

    public String getTrueName() { return trueName; }
    public void setTrueName(String trueName) { this.trueName = trueName; }

    /**
     * 转换为URL参数字符串格式
     */
    public String toParamString() {
        return String.format("cre_type=%d&cre_id=%s&true_name=%s",
                creType, creId, trueName);
    }
}
